package jsf;

import java.io.Serializable;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import util.SessionUtil;
import ejb.UsersBeanRemote;
import entity.Users;

@RequestScoped
@ManagedBean
public class HomeController implements Serializable {

	private static final long serialVersionUID = 1L;
	@EJB(lookup="java:global/EnrollmentManagementEAP/EnrollmentManagementEJB/UsersBean!ejb.UsersBeanRemote")
	UsersBeanRemote userBean;
	private Users user;
	
	public HomeController() {
		SessionUtil.authenticate();
	}
	
	public Users getUser() {
		if(SessionUtil.get("user") != null) {
			Long userId = (Long)SessionUtil.get("user");
			this.user = userBean.get(userId);
		}
		return this.user;
	}
	
}
